// Copyright (c) 2020 Presto Labs Pte. Ltd.
// Author: donggu

#pragma once

// std
#include <map>
#include <memory>
#include <regex>
#include <string>
#include <vector>

// internal
#include "coin2/base/log.h"
#include "coin2/exchange/base/feed/processor.h"
#include "coin2/exchange/base/market/enums.h"
#include "coin2/exchange/bitstamp/feed_v2/update.h"

namespace coin2::exchange::bitstamp::feed_v2 {
namespace impl {
using namespace std::string_literals;
using coin2::exchange::base::market::ExchangeType;
using coin2::exchange::base::market::MarketType;

class BitstampFeedProcessor : public coin2::exchange::base::feed::FeedParsingProcessor {
 public:
  explicit BitstampFeedProcessor(
      const std::string& system_name,
      const coin2::exchange::di::ConstantInjection& ci,
      const feed::RawParserConfig& config)
      : FeedParsingProcessor(
            system_name,
            MarketExchangeApi{MarketType::Spot, ExchangeType::Bitstamp, "v2"},
            ci,
            config,
            "cc/coin2/exchange/bitstamp/feed_v2/schema.json") {
  }

  void OnTopicRecord(const base::executor::TopicRecordPacket& packet) override;

 private:
  inline bool IsKnownMessage(const rapidjson::Value& document);
  inline void ParseChennel(const std::string& channel,
                           std::string* channel_name,
                           std::string* native_symbol);
};
}  // namespace impl
using impl::BitstampFeedProcessor;
}  // namespace coin2::exchange::bitstamp::feed_v2
